package com.spt.springbootzhsx.service.suggest.Get_MTMC_mul_UWL_5;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.hadoop.io.WritableComparable;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class MUbean implements WritableComparable<MUbean> {
    private String m_id;
    private int flag;  //为1表示数据来自影片共现次数，为0表示数据来自用户观影向量

    @Override
    public int compareTo(MUbean o) {
        int n = this.m_id.compareTo(o.m_id);
        if (n != 0) {
            return n;
        } else {
            //将电影共现表的数据放在前面
            return -(this.flag - o.flag);
        }
    }

    @Override
    public void write(DataOutput dataOutput) throws IOException {
        dataOutput.writeUTF(m_id);
        dataOutput.writeInt(flag);
    }

    @Override
    public void readFields(DataInput dataInput) throws IOException {
        this.m_id = dataInput.readUTF();
        this.flag = dataInput.readInt();
    }
}
